<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>机构列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var grid = null;
	//项目类型
	var prjTypCd = "${prjTypCd}";
	$(function () {
	    initForm();
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();
	});
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	//查询按钮事件
	function searchBtnEvent(){
		 $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         data["crtTm"] = $("#crtTm").val();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/project/prjbscinfo/initFundList.do',
	    	method : 'get',
	    	parms:getSearchParams(),
	        columns: [
	            { display: "机构名称", name: 'fundRasInsNm', minWidth: 150 , enabledSort:true},
	            { display: "机构类型名称", name: 'insTypeCdNm', width: 80 , enabledSort:true},
	            { display: '机构状态名称', name: 'insStsNm', minWidth: 60 , enabledSort:true},
	            { display: '机构用途名称', name: 'insUseCdNm', minWidth: 100 , enabledSort:true},
	            { display: '机构编号', name: 'insCode', minWidth: 100 , enabledSort:true},
	            {
	                display: '操作',
	                isSort: false,
	                width: 100,
	                render: function (rowdata, rowindex, value){
	                    var h='<a class="sq-button-hasicon" href="javascript:chooseFundRow(';
	                        h+="'"+rowdata.id+"',";
	                        h+="'"+rowdata.insCode+"',";
	                        h+="'"+rowdata.fundRasInsNm+"'";
	                        h+=')"><i class="sqBtnIco_3"></i>选择</a>'
	                    return h;
	                }
	            }
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:false,
	        rownumbers:true
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	}
	
	function clearBtn(){
		var form = new liger.get("searchBar");
		form.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	function chooseFundRow(id,insCode,fundRasInsNm){
		parent.window.document.getElementById("fundRasInsId").value=id;
		parent.window.document.getElementById("insCode").value=insCode;
		var nm = parent.window.document.getElementById("fundRasInsNm");
		$(nm).html(fundRasInsNm);
		var div =  parent.window.document.getElementById("fundRasInsNmDiv");
		var cstId = parent.window.document.getElementById("cstId").value;
		var prjTypCd = parent.window.document.getElementById("prjTypCd").value;
		var insCode = parent.window.document.getElementById("insCode").value;
		$(div).show();
        if (insCode==="czbank"){
            parent.$("#bkNoDiv").show();
            parent.$("#accNoDiv").show();
            parent.$("#mpDiv").show();
         // === start 存在预留号码时，账号、手机号不可编码 lihaiyang
            if(parent.$("#accNo").val() != null && parent.$("#accNo").val().length>0){
            	 parent.$("#accNo").attr("disabled","disabled");
                 parent.$("#mp").attr("disabled","disabled");
            }
         // === end
        }else{
            parent.$("#bkNoDiv").hide();
            parent.$("#accNoDiv").hide();
            parent.$("#mpDiv").hide();
        }
        if (insCode==="alipay"){
            parent.$("#accNoWSDiv").show();
        }else{
            parent.$("#accNoWSDiv").hide();
        }
        if (insCode==="icbc"){
        	  $("#isHaveUpStructDiv").show();
        }else{
        	  $("#isHaveUpStructDiv").hide();
        }
        if(prjTypCd == "DSFZGCP" && insCode =="jxbank"){//江西银行不做第三方资管城配业务
        	 $.ligerDialog.SQalert({content:'江西银行不允许选择第三方资管城配业务,请重新选择!', SQ_type: "error"});
        return;
        }
		if(cstId&&prjTypCd&&insCode){
		parent.queryCstCreditiInvest();
		}
		parent.$.ligerDialog.close();
		parent.$(".l-dialog,.l-window-mask").css("display","none");

	}
</script>

<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox">
                <div class="label">机构名称</div>
                <div class="field">
                    <input name="fundRasInsNm" id="fundRasInsNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtn"  class="sq-button sq-button-round"><!-- <i class="sqBtnIco_1"></i> -->查询</span>
               <span id="clearBtn" class="sq-button sq-button-round"><!-- <i class="sqBtnIco_19"></i> -->清空</span>
            </div>
        </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</div>
</body>
</html>